<?php
include("../../config/connect.php");
require_once("../../public/common.php");

// 更新cache数据
date_default_timezone_set("Asia/Chongqing");
require_once("../../taobaoapi/funs.php");

//
$sql = "select id from cache_items order by id desc limit 1";
$result = mysql_query( $sql );
if (mysql_num_rows($result) > 0)
{
	$row = mysql_fetch_assoc( $result );
	$idbase = $row["id"];
}
else
	$idbase = 1;
	
$sql = "select id,pay_time,real_pay_fee,num_iid,item_title,commission from report_items where id > $idbase order by id limit 10";
$result = mysql_query( $sql );
while( $result && $row = mysql_fetch_assoc( $result ))
{
	$json = json_decode(GetItemInfo($row["num_iid"]));
	if ($json->code == 1)
	{
	 	$pic_url = $json->pic_url;
		$url = $json->detail_url;
		if ($pic_url != "")
		{
			$sql = "insert into cache_items (id, time, fee, num_iid, item_title, commission, pic_url, url) values 
			(".$row["id"].",'".$row["pay_time"]."',".$row["real_pay_fee"].",'".$row["num_iid"]."','".$row["item_title"]."',".$row["commission"].",'$pic_url','$url')";
			mysql_query( $sql );
//			if (mysql_affected_rows() > 0)
//				$nHasInsert++;
		}
	}
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://www.gouwutu.com/n2/v2/css/nav/jquery.js"></script>
<script type="text/javascript" src="http://www.gouwutu.com/v2/php/jQuery.textSlider.js"></script>
<style type="text/css">
ul,li,img{margin:0;padding:0; list-style:none; border:0;}
#newFanxian .newText { width:948px; height:280px; overflow:hidden;}
#newFanxian ul li { height:280px;}
#newFanxian ul a { float:left; width:189px; height:280px; padding-top:10px; display:block; overflow:hidden; background-color:#fafafa;}
#newFanxian ul a:hover { background-color:#eee;}
#newFanxian ul a img { width:170px; margin:0 10px 0 9px; display:block; background-color:#FFF;}
#newFanxian ul a .title,#newFanxian ul a .price { width:170px; height:40px; line-height:20px; margin:5px 10px 5px 9px; overflow:hidden; color:#2AAACF;}
#newFanxian ul a .price { height:20px; margin:0 10px 0 9px; color:#666333;}
#newFanxian ul a .qz-price em { font-size:14px; font-weight:bold; color:#F30; padding:0 5px;}
#newFanxian ul a .qz-price .fan { font-size:14px; font-weight:bold; color:#333; padding:0 5px;}
 /*伪类事件*/
a:link{color:#777;text-decoration:none;outline:none;cursor:pointer;}
a:visited{color:#777;text-decoration:none;}
a:hover{color:#2287B3;text-decoration:none;}
a:active{color:#777;text-decoration:none;}﻿
</style>
</head>
<body style="margin:0 auto;padding:0; font-size:12px; color:#777; width:948px;">
<div id="newFanxian" style="margin:0;padding:0; width:948px;">
	<div class="newText">
	<ul>
<?PHP
static $i=0;
$sql = "select distinct num_iid, pic_url, url, item_title, time, fee, commission from cache_items where pic_url<>'' order by time desc limit 30";
$result = mysql_query( $sql );
while( $result && $row = mysql_fetch_assoc( $result ))
{
if($i++%5==0)
{
	echo '<li>';
}
?>
<a class="first" href="<?PHP echo $row["url"]; ?>" target="_blank"><img width="170" height="170" title="<?PHP echo $row["item_title"]; ?>" alt="" src="<?PHP echo $row["pic_url"]."_170x170.jpg"; ?>">
                <p class="title" title=""><?PHP echo $row["item_title"]; ?></p>
                <p class="price"><span class="time"><?PHP echo $row["time"]; ?></span></p>
                <p class="price qz-price">售价<em><?PHP echo $row["fee"]; ?></em><span class="coin">返</span><span class="fan"><?PHP echo round($row["commission"] * 0.6, 2); ?></span>元</p>
            </a>

<?PHP 
if ($i % 5 == 0)          
	echo '</li>';
} 

?>
    </li></ul>
    </div>



</div>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(){
        $("#newFanxian").textSlider({line:1,speed:500,timer:4000});
		/*
		
		 static $count = 0;
   $count++;
   echo $count;
   if ($count < 10) {
   Test();
   }
   $count--;
   }
		
		*/
});
</script>